from django.urls import path, re_path
from . import views
from django.contrib.auth.decorators import login_required

app_name = "users"

urlpatterns = [
    path(r"register/", views.RegisterView.as_view(), name="register"),  # 注册
    path(r"usernames/<str:username>/count/", views.CheckUserView.as_view(), name="username"),  # 验证用户是否存在
    path(r"mobiles/<str:phone>/count/", views.CheckPhoneView.as_view(), name="phone"),  # 效验手机号是否注册过
    path(r"image_codes/<str:image_code_id>/", views.ImageCodeView.as_view(), name="Image_code"),
    re_path(r'^sms_codes/(?P<mobile>1[3-9]\d{9})/$', views.SmsCodeView.as_view(), name="Sms_Code"),
    path(r'login/', views.UserLoginView.as_view(), name="User_Login"),
    path(r'logout/', views.LogoutUserView.as_view(), name="Logout_User"),
    # 2.第二种
    # path(r'info/', views.UserInfoView.as_view(), name="UserInfoView"),
    # 3.第三种
    # path(r'info/', login_required(views.UserInfoView.as_view()), name="UserInfoView"),
    # 4.第四种
    path(r'info/', views.UserInfoView.as_view(), name="UserInfoView"),  # 用户中心
    path(r'emails/', views.SendEmailView.as_view(), name="SendEmailView"),  # 发送邮件
    path(r'emails/verification/', views.VerifyEmailView.as_view(), name="VerifyEmailView"),  # 邮件认证修改状态
    path(r'addresses/', views.AddressView.as_view(), name="AddressView"),  # 渲染收货地址页面
    path(r'areas/', views.AreasView.as_view(), name="AreasView"),  # 获取省市区地址联动框
    path(r'addresses/create/', views.AddressCreateView.as_view(), name="AddressCreateView"),  # 新增地址
    path(r'addresses/<int:address_id>/title/', views.AddressTitleRenameView.as_view(), name="AddressTitleRenameView"),
    # 地址标题修改
    path(r'addresses/<int:address_id>/', views.AddressDeleteView.as_view(), name="AddressDeleteView"),  # 地址删除和地址修改

    path(r'addresses/<int:address_id>/default/', views.AddressDefaultView.as_view(), name="AddressDefaultView"),
    # 设置默认地址
    path(r'password/', views.ChangePasswordView.as_view(), name="ChangePasswordView"),  # 修改密码

    path(r'browse_histories/', views.UserBrowseHistoryView.as_view(), name="UserBrowseHistoryView"),  # 保存用户浏览记录
]
